package org.colafries.metadata.factory;

import org.colafries.metadata.driver.Driver;
import org.colafries.metadata.entity.enums.DriverTypeEnum;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author colafries
 * @version v1.0
 * @ClassName DrverFactory
 * @Description Driver 工厂类
 * @date Created in 2024/3/20
 **/
@Component
public class DriverFactory {
    @Resource(name = "mysql")
    private Driver mysqlDriver;
//    @Resource(name = "es")
//    private Driver elasticSearchDriver;
//    @Resource(name = "starrocks")
//    private Driver starrocksDriver;
//    @Resource(name = "clickhouse")
//    private Driver clickHouseDriver;
    @Resource(name = "dameng")
    private Driver damengDriver;

    public Driver getDriver(Integer type) {
        if (DriverTypeEnum.MYSQL.getCode().equals(type)) {
            return mysqlDriver;
        }
        if (DriverTypeEnum.DAMENG.getCode().equals(type)) {
            return damengDriver;
        }
//        else if (DriverTypeEnum.ES.getCode().equals(type)) {
//            return elasticSearchDriver;
//        } else if (DriverTypeEnum.STARROCKS.getCode().equals(type)) {
//            return starrocksDriver;
//        } else if (DriverTypeEnum.CLICKHOUSE.getCode().equals(type)) {
//            return clickHouseDriver;
//        }
        return null;
    }
}